<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>员工入职管理</title>

    <!-- Bootstrap -->
    <link href="http://localhost:8080/PMsystem/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

  </head>
  <body>
<!-- 导航 -->
    <nav class="navbar navbar-default ">
      <div class="container">
        <!-- 小屏幕按钮和logo -->
        <div class="navbar-header">
          <button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a href="#" class="navbar-brand">RM admin</a>
        </div>
        <!-- 小屏幕按钮和logo -->
        <!-- 导航 -->
        <div class="collapse navbar-collapse">
           <ul class=" nav navbar-nav ">
             <li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span> &nbsp;后台首页</a></li>
             <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    组织结构管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/organization/department">部门管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/organization/job">岗位管理</a></li>

                </ul>
            </li>
            <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    人事信息管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/employee/enterAddEmployee">员工入职管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/period/enterPeriod/">试用期管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/dept/out">部门调动管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/post/out">岗位调动管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/leave/out">员工离职管理</a></li>

                </ul>
            </li>
             <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    员工信息中心
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/infoemployee/list">员工信息中心</a></li>


                </ul>
            </li>
            <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    报表管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/statement/newHire">新聘员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/departure">离职员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/deptTurn">部门调动员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/postTurn">岗位调动员工报表</a></li>
                </ul>
            </li>
           </ul>
           <ul class=" nav navbar-nav navbar-right ">
             <li class="dropdown">
                <a href="#" class=" dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">admin
                    <span class="caret"></span>
                </a>
            </li>

             <li><a href="http://localhost:8080/PMsystem//admin/exit"><span class="glyphicon glyphicon-off"></span>&nbsp;退出</a></li>
           </ul>
        </div>
        <!-- 导航 -->
      </div>
    </nav>
   <!-- 导航 -->
   <div class="container-fluid">
       <div class="row">
           <div class="col-md-2">
               <div class="panel-group" id="accordion">
                    <div class="panel panel-default">
                      <div class="panel-heading">
                          <h4 class="panel-title">
                              <a data-toggle="collapse" data-parent="#accordion"
                              href="#collapseThree" style="text-decoration: none;">
                             普通入职
                              </a>
                          </h4>
                      </div>
                      <div id="collapseThree" class="panel-collapse collapse in">
                          <div class="panel-body">
                              <table class="table table-hover">
                              <tbody>
                                <tr>
                                  <td style="border:none;"><a href="#" style="text-decoration: none;">普通入职</a></td>
                                </tr>
                              </tbody>
                            </table>
                          </div>
                      </div>
                  </div>
              </div>

           </div>
           
          	<!--  <form action="${pageContext.request.contextPath}/employee/addEmployee" method="post"> -->
             <div class="col-sm-10">
              
                <div class="panel-group" id="accordion3">
                  <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <a data-toggle="collapse" data-parent="#accordion3"
                            href="#collapseFive" style="text-decoration: none;">
                              员工信息录入
                            </a>
                        </h4>
                    </div>
                     <!-- 主体内容 -->
                     <div id="collapseFive" class="panel-collapse collapse in">
                    <div class="panel-body">
                     <div class="row">
                    <div class=" col-md-3" style="margin-left:10px;">
                     <div class="row">
                        <div class="input-group" >
                           <span class="input-group-addon">姓名</span>
                           <input type="text" class="form-control" name="empName" id="empName" placeholder="请输入姓名">
                       </div><sapn id="empNameErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">性别</span>
                           <select class="form-control" name="empSex" id="empSex">
                             <option value="男">男</option>
                             <option value="女">女</option>
                           </select>                          
                       </div><sapn id="empSexErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">出生日期</span>
                           <input type="date"  class="form-control" name="empBirthday" id="empBirthday">
                       </div><sapn id="empBirthdayErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">联系电话</span>
                           <input type="text" class="form-control" name="empPhone" id="empPhone" placeholder="请输入联系电话">
                       </div><sapn id="empPhoneErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">电子邮件</span>
                           <input type="text" class="form-control" name="empEmail" id="empEmail" placeholder="请输入电子邮件">
                       </div><sapn id="empEmailErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">婚姻状况</span>
                           <select class="form-control" name="empMarriage" id="empMarriage">
                             <option value="未婚">未婚</option>
                             <option value="已婚">已婚</option>
                             <option value="丧偶">丧偶</option>
                             <option value="离婚">离婚</option>
                             <option value="其它">其它</option>
                           </select>
                       </div><sapn id="empMarriageErrorMSG"></sapn><br>
                       
                      <div class="input-group">
                        <span class="input-group-addon">血型</span>
                        <select class="form-control" name="empBlood" id="empBlood">
                          <option value="A">A型</option>
                          <option value="B">B型</option>
                          <option value="AB">AB型</option>
                          <option value="O">O 型</option>
                          <option value="其它">其它血型</option>
                        </select>
                      </div><sapn id="empBloodErrorMSG"></sapn><br>
					
					  <div class="input-group">
                           <span class="input-group-addon">身高</span>
                           <input type="text" class="form-control" name="empHeight" id="empHeight" placeholder="请输入身高">
                       </div><sapn id="empHeightErrorMSG"></sapn><br>
					
                     </div>
                   </div>


                      <div class=" col-md-4 " style="margin-left:10px">
                        <div class="row">
                       <div class="input-group">
                           <span class="input-group-addon">身份证号</span>
                           <input type="text" class="form-control" name="empIdcard" id="empIdcard" placeholder="请输入身份证号">
                       </div><sapn id="empIdcardErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">部门</span>
                           <select class="form-control" name="empDept" id="empDept">
								<c:forEach items="${departments}" var="department">
									<option value="${department.deptId}">${department.deptName}</option>
								</c:forEach>
                           </select>
                       </div><sapn id=""></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">岗位</span>
                           <select class="form-control" name="empPost" id="empPost">
								<c:forEach items="${posts}" var="post">
									<option value="${post.postId}">${post.postName}</option>
								</c:forEach>
                           </select>
                       </div><sapn id=""></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">民族</span>
                           <select class="form-control" name="empNation" id="empNation">
                             <option value="民族1">民族1</option>
                             <option value="民族2">民族2</option>
                           </select>
                       </div><sapn id="empNationErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">籍贯</span>
                           <input type="text" class="form-control" name="empBirthplace" id="empBirthplace" placeholder="请输入籍贯">
                       </div><sapn id="empBirthplaceErrorMSG"></sapn><br>



                       <div class="input-group">
                           <span class="input-group-addon">出生地</span>
                           <input type="text" class="form-control" name="empBornPlace" id="empBornPlace" placeholder="请输入出生地">
                       </div><sapn id="empBornPlaceErrorMSG"></sapn><br>

                       <div class="input-group">
                           <span class="input-group-addon">户口所在地</span>
                           <input type="text" class="form-control" name="empAccount" id="empAccount" placeholder="请输入户口所在地">
                       </div><sapn id="empAccountErrorMSG"></sapn><br>
						
					<div class="input-group">
                          <span class="input-group-addon">参加工作日期</span>
                          <input type="date"  class="form-control" id="empEnterDate" name="empEnterDate" value="2013">
                      </div><sapn id="empEnterDateErrorMSG"></sapn><br>
						
                     </div>
                   </div>


                  <div class="col-md-4" style="margin-left:10px">
                    <div class="row">

                      <div class="input-group">
                          <span class="input-group-addon">入职日期</span>
                          <input type="date"  class="form-control " name="empJoinDate" id="empJoinDate" >
                      </div><sapn id="empJoinDateErrorMSG"></sapn><br>



                      <div class="input-group">
                        <span class="input-group-addon">用工形式</span>
                        <select class="form-control" id="empJobon" name="empJobon" id="empJobon">
                          <option value="正式员工">正式员工</option>
                          <option value="临时员工">临时员工</option>
                        </select>
                      </div><sapn id="empJobonErrorMSG"></sapn><br>

                      <div class="input-group">
                        <span class="input-group-addon">人员来源</span>
                        <select class="form-control" name="empSource" id="empSource">
                          <option value="校园招聘">校园招聘</option>
                          <option value="社会招聘">社会招聘</option>
                          <option value="其它">其它</option>
                        </select>
                      </div><sapn id="empSourceErrorMSG"></sapn><br>

                      <div class="input-group">
                        <span class="input-group-addon">政治面貌</span>
                        <select class="form-control" name="empPolitical" id="empPolitical">
                          <option value="党员">党员</option>
                          <option value="预备党员">预备党员</option>
                          <option value="团员">团员</option>
                          <option value="其他">其他</option>
                        </select>
                      </div><sapn id="empPoliticalErrorMSG"></sapn><br>

                      <div class="input-group">
                        <span class="input-group-addon">最高学历</span>
                        <select class="form-control" name="empEducation" id="empEducation">
                          <option value="无学历">无学历</option>
                          <option value="小学">小学</option>
                          <option value="初中">初中</option>
                          <option value="高中">高中</option>
                          <option value="大学">大学</option>
                        </select>
                      </div><sapn id="empEducationErrorMSG"></sapn><br>

                      <div class="input-group">
                        <span class="input-group-addon">最高学位</span>
                        <select class="form-control" name="empDegree" id="empDegree">
                          <option value="无学位">无学位</option>
                          <option value="学士">学士</option>
                          <option value="双学士">双学士</option>
                          <option value="硕士">硕士</option>
                          <option value="博士">博士</option>
                          <option value="博士后">博士后</option>
                        </select>
                      </div><sapn id="empDegreeErrorMSG"></sapn><br>

                      <div class="input-group">
                          <span class="input-group-addon">毕业院校</span>
                          <input type="text" class="form-control" name="empAcademy" placeholder="请输入毕业院校" id="empAcademy">
                      </div><sapn id="empAcademyErrorMSG"></sapn><br>
					
					  <div class="input-group">
                          <span class="input-group-addon">所学专业</span>
                          <input type="text" class="form-control" name="empProfession" placeholder="请输入所学专业" id="empProfession">
                      </div><sapn id="empProfessionErrorMSG"></sapn><br>
						
					  <div class="input-group">
                          <span class="input-group-addon">毕业日期</span>
                          <input type="date" class="form-control " name="empGradute" id="empGradute">
                      </div><sapn id="empGraduteErrorMSG"></sapn><br>
						


                      </div>
                    </div>
                  </div>--
                </div>
              </div>
            </div>
          </div>
          
          <div class="row" style="margin-bottom: 40px;padding:0px 20px;">
              <button  class="btn btn-primary" id="validateEmail">验证邮箱信息</button><span id="validEmailMsg" style="color:red">&nbsp&nbsp邮箱未验证 </span>
          </div>
          <div class="row" style="margin-bottom: 40px;padding:0px 20px;">
              <button  class="btn btn-primary" id="submitInfo">提交员工信息</button>
          </div>
          
          
         		<div class="row" style="margin-bottom: 40px;padding:0px 20px;">
                  ${mage}
                </div>
                <div class="row" id="start_date" style="">
                  <div class="col-sm-12">
                  <div class="panel-group" id="accordion2">
                  <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <a data-toggle="collapse" data-parent="#accordion2"
                            href="#collapseFour" style="text-decoration: none;">
                              添加试用期
                            </a>
                            
                        </h4>
                    </div>
                    <div id="collapseFour" class="panel-collapse collapse">
                        <div class="panel-body">
                            <table class="table table-hover">
                            <tbody>
                              <tr>
                                <td style="border:none;">
                                  <div class="col-md-4">
                                    <div class="input-group">
                                        <span class="input-group-addon">试用期开始日期</span>
                                        <input type="date" class="form-control" name="probDateS" id="probDateS">
                                    </div><br>
                                    <div class="input-group">
                                        <span class="input-group-addon">试用期结束日期</span>
                                        <input type="date"  class="form-control" name="probDateE" id="probDateE">
                                    </div><br>
                                  </div>

                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                    </div>


                  </div>
                </div>
                </div>
              </div>

                <div class="row" style="margin-bottom: 40px;padding:0px 20px;">
                  <button  class="btn btn-primary" id="submitProbation">提交试用期信息</button>
                </div>


            
              </div>
              <!-- </form> -->
              <!-- 主体内容 -->
              
              
            </div>
           </div>
			<input  type="hidden" id="callBackempNum"  value=""/>




    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://localhost:8080/PMsystem/js/jquery-3.2.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="http://localhost:8080/PMsystem/js/bootstrap.min.js"></script>

    <script type="text/javascript">
    var emailReady = false;
    var successAdd = false;
    $(document).ready(function(){
    	$("#validateEmail").click(function(){
    		if($("#empEmail").val() == ""){
    			alert("还未填写邮箱信息");
    		}else{
        		var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); //正则表达式
        		if(!reg.test($("#empEmail").val())){
        			alert("邮箱格式不正确");
        		}
        		else{
        			$.ajax({
    					type:"post",
    					url:"http://localhost:8080/PMsystem/employee/validateEmail",
    					data: {
    						empEmail: $("#empEmail").val()
    					},
        				dataType: "json",
    					success: function(data){
    				    	if(data.validKey){
    				    		alert("邮箱验证成功！");
    				    		$("#validEmailMsg").html("&nbsp&nbsp邮箱验证已通过");
    				    		emailReady = data.validKey
    				    	}else{
    				    		alert("邮箱已存在，请另选邮箱");
    				    	}
    					},
    					error:   function(jqXHR){
    						alert("发生错误：" + jqXHR.status);
    					},
        			})
        		}
    		}

    	})	
    });
    //提交员工基本信息
    $(document).ready(function(){	
    	$("#submitInfo").click(function(){
    		if(emailReady){
				$.ajax({
					type:"post",
					url:"http://localhost:8080/PMsystem/employee/addEmpInfoPartOne",	
					data: {
						empName       : $("#empName").val(),
						empSex        : $("#empSex").val(),
						empBirthday   : $("#empBirthday").val(),
						empPhone      : $("#empPhone").val(),  
						empEmail      : $("#empEmail").val(),
						empMarriage   : $("#empMarriage").val(),
						empIdcard     : $("#empIdcard").val(),
						empDept       : $("#empDept").val(),
						empPost       : $("#empPost").val(),
						empNation     : $("#empNation").val(),
						empBirthplace : $("#empBirthplace").val(),
						empHeight     : $("#empHeight").val(),
						empBornPlace  : $("#empBornPlace").val(),
						empAccount    : $("#empAccount").val(),
						empJoinDate   : $("#empJoinDate").val(),
						empEnterDate  : $("#empEnterDate").val(),
						empJobon      : $("#empJobon").val(),
						empSource     : $("#empSource").val(),
						empPolitical  : $("#empPolitical").val(),
						empBlood      : $("#empBlood").val(),
						empDegree     : $("#empDegree").val(),
						empAcademy    : $("#empAcademy").val(),
						empProfession : $("#empProfession").val(),
						empGradute    : $("#empGradute").val(),
						empDegree     : $("#empDegree").val(),
						empEducation  : $("#empEducation").val()		
					},
					dataType: "json",
					success: function(data){
						if(data.errorMsg){
							alert("存在错误信息"+data.errorMsgInfo);		
						}else{//没有错误信息
							if(data.successAdd){
								if(data.sendEmail){
									alert("信息存入成功！ \n 员工编号分配成功:"+data.empNum+"，编号已发送至您注册的邮箱！");
									successAdd = data.successAdd;
									$("#callBackempNum").val(data.empNum);
								}else{
									alert("存入信息成功，发送邮件失败，请牢记员工号："+$("#callBackempNum").val());
									successAdd = data.successAdd;
									$("#callBackempNum").val(data.empNum);
								}
							}else{
								alert("存入信息失败，请重试");
							}							
						}
					},
					error:   function(jqXHR){
						alert("请重新尝试！：" + jqXHR.status);
					},
				});
    		}
    		else{
    			alert("邮箱验证未通过！");
    		}
    	});
    });
    
    
    
    $(document).ready(function(){
    	$("#submitProbation").click(function(){
    		if(true){
    			//Ajax提交员工试用期
    			$.ajax({
					type:"post",
					url:"http://localhost:8080/PMsystem/employee/addEmpProbation",
					data: {
						probDateS       : $("#probDateS").val(),
						probDateE       : $("#probDateE").val(),
						empNum          : $("#callBackempNum").val()
					},
					dataType: "json",
					success:	function(data){
									if(data.proAddSuccess){
										alert("添加试用期成功");
									}else{
										alert("存入失败！");
									}
								},
					error: function(jqXHR){
								alert("请重新尝试！发生错误：" + jqXHR.status);
							}
					
    			});    					    			
    			
    		}else{
    			alert("请先提交员工基本信息");
    		}
    		
    	});
    });
    </script>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</body>
</html>